package com.gitee.jmash.storage;

import com.gitee.jmash.storage.service.*;
import jakarta.enterprise.inject.spi.CDI;

/**
 * 模块服务工厂类.
 *
 * @author CGD
 */
public class StorageFactory {


  public static StorageOrganInfoRead getStorageOrganInfoRead(String tenant) {
    return CDI.current().select(StorageOrganInfoRead.class).get().setTenant(tenant);
  }

  public static StorageOrganUserRead getStorageOrganUserRead(String tenant) {
    return CDI.current().select(StorageOrganUserRead.class).get().setTenant(tenant);
  }

  public static StorageOrganBrowserWrite getStorageOrganBrowserWrite(String tenant) {
    return CDI.current().select(StorageOrganBrowserWrite.class).get().setTenant(tenant);
  }

  public static StorageOrganInfoWrite getStorageOrganInfoWrite(String tenant) {
    return CDI.current().select(StorageOrganInfoWrite.class).get().setTenant(tenant);
  }

  public static StorageOrganUserWrite getStorageOrganUserWrite(String tenant) {
    return CDI.current().select(StorageOrganUserWrite.class).get().setTenant(tenant);
  }

  /**
   * CDI回收实例.
   */
  public static void destroy(Object instance) {
    if (null != instance) {
      CDI.current().destroy(instance);
    }
  }
}
